import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutterwebsite/model/product.dart';
import 'dart:async';

import 'package:flutterwebsite/pages/home_banner.dart';
import 'package:flutterwebsite/pages/home_product_page.dart';
import 'package:flutterwebsite/services/product_service.dart';
class HomePage extends StatefulWidget{

  @override
  HomeState createState() =>HomeState();



}
class HomeState extends State<HomePage>{
  @override
  void initState() {
//    super.initState();
    getProductList();
  }
  //产品数据数组
  ProductListModel listdata=ProductListModel([]);

  //获取产品数据数组
  void getProductList() async {
    var data=await getProductsResult();
    ProductListModel list=ProductListModel.fromJson(data);
    setState(() {
      listdata.data.addAll(list.data);
    });
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: <Widget>[
          //轮播图
          BannerWidget(),
          //产品列表
          HomeProductPage(listdata),
        ],
      ),
    );
  }
}